﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		IRepository (Generic).cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            IRepository (Generic).cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Dexter.Repository {
	/// <summary>
	/// 	Rapresents a repository of domain objects.
	/// </summary>
	/// <typeparam name = "T">The type of elements in the repository</typeparam>
	public interface IRepository <T> : ICollection <T> , IQueryable <T> {
		/// <summary>
		/// 	Specifies the related objects to include in the query results.
		/// </summary>
		/// <param name = "subSelector">Identifies the field or property to be retrieved. 
		/// 	If the expression does not identify a field or property that represents a one-to-one or one-to-many relationship, an exception is thrown.</param>
		/// <returns>A new System.Linq.IQueryable&lt;T&gt; with the defined query path.</returns>
		/// <remarks>
		/// 	You cannot specify the loading of two levels of relationships (for example, Orders.OrderDetails).
		/// </remarks>
		IQueryable <T> Include ( Expression <Func <T , object>> subSelector );

		/// <summary>
		/// 	Specifies the related objects to include in the query results.
		/// </summary>
		/// <param name = "subSelector">Identifies the field or property to be retrieved.
		/// 	If the expression does not identify a field or property that represents a one-to-one or one-to-many relationship, an exception is thrown.</param>
		/// <param name = "useCache">if set to <c>true</c> the resulset will be cached.</param>
		/// <returns>
		/// 	A new System.Linq.IQueryable&lt;T&gt; with the defined query path.
		/// </returns>
		/// <remarks>
		/// 	You cannot specify the loading of two levels of relationships (for example, Orders.OrderDetails).
		/// </remarks>
		IQueryable <T> Include ( Expression <Func <T , object>> subSelector , bool useCache );

		/// <summary>
		/// 	Specifies the related objects to include in the query results.
		/// </summary>
		/// <param name = "subSelector">Identifies the field or property to be retrieved.
		/// 	If the expression does not identify a field or property that represents a one-to-one or one-to-many relationship, an exception is thrown.</param>
		/// <param name = "useCache">if set to <c>true</c> the resulset will be cached.</param>
		/// <param name = "regionName">The region name.</param>
		/// <returns>
		/// 	A new System.Linq.IQueryable&lt;T&gt; with the defined query path.
		/// </returns>
		/// <remarks>
		/// 	You cannot specify the loading of two levels of relationships (for example, Orders.OrderDetails).
		/// </remarks>
		IQueryable <T> Include ( Expression <Func <T , object>> subSelector , bool useCache , string regionName );

		/// <summary>
		/// 	Remove all items from the specified region;
		/// </summary>
		/// <param name = "regionName">Name of the region.</param>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="regionName"/> is <c>null</c> or <c>empty</c>.</exception>
		void ClearCacheRegion ( string regionName );
	}
}
